From 5817e76da44a000fa8a8d036d36e4f4db77ebee7 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 11 Mar 2016 12:18:17 -0800 Subject: [PATCH] Fix installing git repos with lockfiles Just an erroneous assertion that needs to be ignored. Closes #2466 --- src/cargo/core/resolver/encode.rs | 8 ++++++- tests/test_cargo_install.rs | 35 +++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/src/cargo/core/resolver/encode.rs b/src/cargo/core/resolver/encode.rs index 93d359655..c2d187c3f 100644 --- a/src/cargo/core/resolver/encode.rs +++ b/src/cargo/core/resolver/encode.rs @@ -95,7 +95,13 @@ fn build_path_deps(root: &Package, map: &mut HashMap, config: &Config) -> CargoResult<()> { - assert!(root.package_id().source_id().is_path()); + // If the root crate is *not* a path source, then we're probably in a + // situation such as `cargo install` with a lock file from a remote + // dependency. In that case we don't need to fixup any path dependencies (as + // they're not actually path dependencies any more), so we ignore them. + if !root.package_id().source_id().is_path() { + return Ok(()) + } let deps = root.dependencies() .iter() diff --git a/tests/test_cargo_install.rs b/tests/test_cargo_install.rs index f385086ca..f4a322f4c 100644 --- a/tests/test_cargo_install.rs +++ b/tests/test_cargo_install.rs @@ -596,3 +596,38 @@ third party subcommand `cargo-fail[..]` exited unsuccessfully To learn more, run the command again with --verbose. ")); }); + +test!(git_with_lockfile { + let p = git::repo(&paths::root().join("foo")) + .file("Cargo.toml", r#" + [package] + name = "foo" + version = "0.1.0" + authors = [] + + [dependencies] + bar = { path = "bar" } + "#) + .file("src/main.rs", "fn main() {}") + .file("bar/Cargo.toml", r#" + [package] + name = "bar" + version = "0.1.0" + authors = [] + "#) + .file("bar/src/lib.rs", "fn main() {}") + .file("Cargo.lock", r#" + [root] + name = "foo" + version = "0.1.0" + dependencies = [ "b 0.1.0" ] + + [[package]] + name = "bar" + version = "0.1.0" + "#); + p.build(); + + assert_that(cargo_process("install").arg("--git").arg(p.url().to_string()), + execs().with_status(0)); +}); -- 2.30.2